package com.thoughtworks.xml;

import com.thoughtworks.xml.model.Customer;
import com.thoughtworks.xml.service.CustomerService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by yrzhang on 10/8/16.
 */
public class Application {

    public List<Customer> ShowCustomers() {

        ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext-xml.xml");
        CustomerService service = appContext.getBean("customerService", CustomerService.class);

        return service.findAll();
    }

    public String getName() {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext-xml.xml");
        CustomerService service = appContext.getBean("customerService", CustomerService.class);

        return service.getName();
    }

}
